#pragma once
#include "ScoreSystem.h"

HighScorePage::HighScorePage(void)
{
	Background = Object2D(800,600);
	Background.setPosition(400,300);
	Continue = Object2D(642,65);
	Continue.setPosition(400,550);
}

HighScorePage::~HighScorePage(void)
{
}

void HighScorePage::draw()
{
	glColor3f(1,1,1);
	Background.drawPlane(SceneImages[0].texID);
	Continue.drawPlane(SceneImages[1].texID);

	list<pair<string,int>>::iterator i;
	int j = 0;
	glColor3f(0,0,0);
	for(i = ScoreList.begin(); i != ScoreList.end(); i++)
	{
		printw(300,50+(50*j-10),0,"%i%s - %s %i", j+1, (j<3)?((j<2)?((j==0)?"st":"nd"):"rd"):"th", i->first.c_str(), i->second);
		j++;
	}
}

void HighScorePage::update()
{
}

void HighScorePage::reset()
{
}

void HighScorePage::freeResource()
{
	freeTexture(&SceneImages[0]);
	freeTexture(&SceneImages[1]);
}

void HighScorePage::loadResource()
{
	ScoreList = LeaderBoard::getInstance().getScoreList();
	LoadTGA( &SceneImages[0], "images/scorepage/Image_Background.tga");
	LoadTGA( &SceneImages[1], "images/scorepage/Image_Continue.tga");
}

void HighScorePage::handleKeyboard(int key, int x, int y)
{
	switch(key)
	{
	case 27: glutLeaveMainLoop(); 
	//	SceneManager::getInstance().changeScene("Pause");
		break;
	default: break;
	}
}

void HighScorePage::handleKeyboardUp(int key, int x, int y)
{
	switch(key)
	{
	case ' ':
		SceneManager::getInstance().changeScene("Main_Menu");
		break;
	default:
		break;
	}
}

void HighScorePage::handleKeyboardSpecial(int key, int x, int y)
{
}

void HighScorePage::getMid(int &x, int &y)
{
}

void HighScorePage::handleMouseClick(int button, int state, int x, int y)
{
}

void HighScorePage::handleMouseMove(int x, int y)
{
}